﻿using System;
using System.Data;
using YuuzleComic.Collect;

public partial class manage_collect_Collect : YuuzleComic.Web.UI.BasePage
{
    public manage_collect_Collect()
    {
        //Authority_Code = "S011";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Collect cl = new Collect();
        if (Request.QueryString["type"] == "Site")
        {
            if (Request.QueryString["id"] == null || Request.QueryString["num"] == null
            || Request.QueryString["id"].Trim().Equals("") || Request.QueryString["num"].Trim().Equals("")
            || Request.QueryString["norepeat"] == null)
            {
                PageError("参数无效", "");
            }
            bool norepeat = false;
            if (Request.QueryString["norepeat"] == "1")
                norepeat = true;
            int num = 0, id = 0;
            id = int.Parse(Request.QueryString["id"]);
            num = int.Parse(Request.QueryString["num"]);
            //判断采集规则中栏目是否合法（wxh 2008-6-24）
            if (!IsExistClassID(id))
            {
                PageError("栏目不存在，请检查。  <a href=\"Collect_List.aspx\">返回管理", "");
            }
            if (id < 1 || num < 1)
                PageError("输入了无效的参数!", "");
            cl.Collecting(id, num, norepeat);
        }
        else if (Request.QueryString["type"] == "Chapter")
        {

            cl.CollectingChapter(Request.QueryString["id"], true);

        }

        Response.Write("<br />釆集结束  <a href=\"Collect_List.aspx\">返回管理</a>");
        Response.End();
    }

    /// <summary>
    /// 判断采集规则中栏目是否合法（wxh 2008-6-24）
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    private bool IsExistClassID(int id)
    {
        bool result = false;
        string classID = "";
        YuuzleComic.Collect.Collect collect = new YuuzleComic.Collect.Collect();
        DataTable dt = collect.GetSite(id);
        if (dt.Rows.Count > 0) //获取栏目ID
        {
            classID = dt.Rows[0]["ClassID"].ToString();
        }
        if (!string.IsNullOrEmpty(classID))　//栏目ID是否在栏目中存在
        {
            //YuuzleComic.AccessDAL.News news = new YuuzleComic.AccessDAL.News();
            //YuuzleComic.CMS.News news = new YuuzleComic.CMS.News();
            //IDataReader dr = news.getClassInfo(classID, 0);
            //if (dr.Read()) {
            //    result = true;
            //}
        }
        return true;
    }
}
